using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;

namespace Data_Access_Tier
{
	public class HRM_WELFAREData : DatabaseObjectBase
	{
		public HRM_WELFAREData()
		{
			Initialize(true);
		}
		public HRM_WELFAREData(Boolean newConnection)
		{
			Initialize(newConnection);
		}

		public Int32 HRM_WELFARE_Insert(String WelfareCode, String WelfareName, DateTime PrepareFromDate, DateTime PrepareToDate, DateTime RegisterFromDate, DateTime RegisterToDate, DateTime PerformFromDate, DateTime PerformToDate, String Purpose, String Form, String Location, Int32 Quantity, Int32 Status, Decimal MoneyOneEmployee, Decimal MoneyOneCompany, Decimal MoneyOneTotal, Decimal MoneyAllEmployee, Decimal MoneyAllCompany, Decimal MoneyAllTotal, Decimal MoneyTotal, String PartnerName, String PartnerPhone, String PartnerAddress, String PersonName, String PersonPosition, String PersonPhone, String PersonEmail, String PersonAddress, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.InsertCommand = new SqlCommand("HRM_WELFARE_Insert");
				_dbadapter.InsertCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.InsertCommand.Connection = _dbconn;
				_trans = _dbconn.BeginTransaction();
				_dbadapter.InsertCommand.Transaction = _trans;
				_dbadapter.InsertCommand.Parameters.Clear();
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@WelfareName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PrepareFromDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PrepareToDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@RegisterFromDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@RegisterToDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PerformFromDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PerformToDate", SqlDbType.DateTime));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Purpose", SqlDbType.NVarChar, 1000));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Form", SqlDbType.NVarChar, 1000));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Location", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Quantity", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyOneEmployee", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyOneCompany", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyOneTotal", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyAllEmployee", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyAllCompany", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyAllTotal", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@MoneyTotal", SqlDbType.Money));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PartnerName", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PartnerPhone", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PartnerAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonPosition", SqlDbType.NVarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonEmail", SqlDbType.VarChar, 100));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.InsertCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 1000));
				_dbadapter.InsertCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.InsertCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				SqlString WelfareNameSQL = WelfareName;
				_dbadapter.InsertCommand.Parameters["@WelfareName"].Value = WelfareNameSQL;
				SqlDateTime PrepareFromDateSQL = SqlDateTime.Null;
				if (PrepareFromDate > DateTime.MinValue)
				{
					try
					{
						PrepareFromDateSQL = PrepareFromDate;
					}
					catch (Exception ePrepareFromDate)
					{
						String PrepareFromDateMessage = ePrepareFromDate.Message;
						PrepareFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@PrepareFromDate"].Value = PrepareFromDateSQL;
				SqlDateTime PrepareToDateSQL = SqlDateTime.Null;
				if (PrepareToDate > DateTime.MinValue)
				{
					try
					{
						PrepareToDateSQL = PrepareToDate;
					}
					catch (Exception ePrepareToDate)
					{
						String PrepareToDateMessage = ePrepareToDate.Message;
						PrepareToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@PrepareToDate"].Value = PrepareToDateSQL;
				SqlDateTime RegisterFromDateSQL = SqlDateTime.Null;
				if (RegisterFromDate > DateTime.MinValue)
				{
					try
					{
						RegisterFromDateSQL = RegisterFromDate;
					}
					catch (Exception eRegisterFromDate)
					{
						String RegisterFromDateMessage = eRegisterFromDate.Message;
						RegisterFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@RegisterFromDate"].Value = RegisterFromDateSQL;
				SqlDateTime RegisterToDateSQL = SqlDateTime.Null;
				if (RegisterToDate > DateTime.MinValue)
				{
					try
					{
						RegisterToDateSQL = RegisterToDate;
					}
					catch (Exception eRegisterToDate)
					{
						String RegisterToDateMessage = eRegisterToDate.Message;
						RegisterToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@RegisterToDate"].Value = RegisterToDateSQL;
				SqlDateTime PerformFromDateSQL = SqlDateTime.Null;
				if (PerformFromDate > DateTime.MinValue)
				{
					try
					{
						PerformFromDateSQL = PerformFromDate;
					}
					catch (Exception ePerformFromDate)
					{
						String PerformFromDateMessage = ePerformFromDate.Message;
						PerformFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@PerformFromDate"].Value = PerformFromDateSQL;
				SqlDateTime PerformToDateSQL = SqlDateTime.Null;
				if (PerformToDate > DateTime.MinValue)
				{
					try
					{
						PerformToDateSQL = PerformToDate;
					}
					catch (Exception ePerformToDate)
					{
						String PerformToDateMessage = ePerformToDate.Message;
						PerformToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.InsertCommand.Parameters["@PerformToDate"].Value = PerformToDateSQL;
				SqlString PurposeSQL = Purpose;
				_dbadapter.InsertCommand.Parameters["@Purpose"].Value = PurposeSQL;
				SqlString FormSQL = Form;
				_dbadapter.InsertCommand.Parameters["@Form"].Value = FormSQL;
				SqlString LocationSQL = Location;
				_dbadapter.InsertCommand.Parameters["@Location"].Value = LocationSQL;
				SqlInt32 QuantitySQL = Quantity;
				_dbadapter.InsertCommand.Parameters["@Quantity"].Value = QuantitySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.InsertCommand.Parameters["@Status"].Value = StatusSQL;
				SqlMoney MoneyOneEmployeeSQL = MoneyOneEmployee;
				_dbadapter.InsertCommand.Parameters["@MoneyOneEmployee"].Value = MoneyOneEmployeeSQL;
				SqlMoney MoneyOneCompanySQL = MoneyOneCompany;
				_dbadapter.InsertCommand.Parameters["@MoneyOneCompany"].Value = MoneyOneCompanySQL;
				SqlMoney MoneyOneTotalSQL = MoneyOneTotal;
				_dbadapter.InsertCommand.Parameters["@MoneyOneTotal"].Value = MoneyOneTotalSQL;
				SqlMoney MoneyAllEmployeeSQL = MoneyAllEmployee;
				_dbadapter.InsertCommand.Parameters["@MoneyAllEmployee"].Value = MoneyAllEmployeeSQL;
				SqlMoney MoneyAllCompanySQL = MoneyAllCompany;
				_dbadapter.InsertCommand.Parameters["@MoneyAllCompany"].Value = MoneyAllCompanySQL;
				SqlMoney MoneyAllTotalSQL = MoneyAllTotal;
				_dbadapter.InsertCommand.Parameters["@MoneyAllTotal"].Value = MoneyAllTotalSQL;
				SqlMoney MoneyTotalSQL = MoneyTotal;
				_dbadapter.InsertCommand.Parameters["@MoneyTotal"].Value = MoneyTotalSQL;
				SqlString PartnerNameSQL = PartnerName;
				_dbadapter.InsertCommand.Parameters["@PartnerName"].Value = PartnerNameSQL;
				SqlString PartnerPhoneSQL = PartnerPhone;
				_dbadapter.InsertCommand.Parameters["@PartnerPhone"].Value = PartnerPhoneSQL;
				SqlString PartnerAddressSQL = PartnerAddress;
				_dbadapter.InsertCommand.Parameters["@PartnerAddress"].Value = PartnerAddressSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.InsertCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPositionSQL = PersonPosition;
				_dbadapter.InsertCommand.Parameters["@PersonPosition"].Value = PersonPositionSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.InsertCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonEmailSQL = PersonEmail;
				_dbadapter.InsertCommand.Parameters["@PersonEmail"].Value = PersonEmailSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.InsertCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.InsertCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.InsertCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_WELFARE_Insert: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_WELFARE_Insert: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.InsertCommand != null)
					_dbadapter.InsertCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_WELFARE_Update(String WelfareCode, String WelfareName, DateTime PrepareFromDate, DateTime PrepareToDate, DateTime RegisterFromDate, DateTime RegisterToDate, DateTime PerformFromDate, DateTime PerformToDate, String Purpose, String Form, String Location, Int32 Quantity, Int32 Status, Decimal MoneyOneEmployee, Decimal MoneyOneCompany, Decimal MoneyOneTotal, Decimal MoneyAllEmployee, Decimal MoneyAllCompany, Decimal MoneyAllTotal, Decimal MoneyTotal, String PartnerName, String PartnerPhone, String PartnerAddress, String PersonName, String PersonPosition, String PersonPhone, String PersonEmail, String PersonAddress, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_WELFARE_Update");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@WelfareName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PrepareFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PrepareToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RegisterFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RegisterToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PerformFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PerformToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Purpose", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Form", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Location", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Quantity", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneEmployee", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneCompany", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllEmployee", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllCompany", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerName", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPosition", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonEmail", SqlDbType.VarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.UpdateCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				SqlString WelfareNameSQL = WelfareName;
				_dbadapter.UpdateCommand.Parameters["@WelfareName"].Value = WelfareNameSQL;
				SqlDateTime PrepareFromDateSQL = SqlDateTime.Null;
				if (PrepareFromDate > DateTime.MinValue)
				{
					try
					{
						PrepareFromDateSQL = PrepareFromDate;
					}
					catch (Exception ePrepareFromDate)
					{
						String PrepareFromDateMessage = ePrepareFromDate.Message;
						PrepareFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PrepareFromDate"].Value = PrepareFromDateSQL;
				SqlDateTime PrepareToDateSQL = SqlDateTime.Null;
				if (PrepareToDate > DateTime.MinValue)
				{
					try
					{
						PrepareToDateSQL = PrepareToDate;
					}
					catch (Exception ePrepareToDate)
					{
						String PrepareToDateMessage = ePrepareToDate.Message;
						PrepareToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PrepareToDate"].Value = PrepareToDateSQL;
				SqlDateTime RegisterFromDateSQL = SqlDateTime.Null;
				if (RegisterFromDate > DateTime.MinValue)
				{
					try
					{
						RegisterFromDateSQL = RegisterFromDate;
					}
					catch (Exception eRegisterFromDate)
					{
						String RegisterFromDateMessage = eRegisterFromDate.Message;
						RegisterFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@RegisterFromDate"].Value = RegisterFromDateSQL;
				SqlDateTime RegisterToDateSQL = SqlDateTime.Null;
				if (RegisterToDate > DateTime.MinValue)
				{
					try
					{
						RegisterToDateSQL = RegisterToDate;
					}
					catch (Exception eRegisterToDate)
					{
						String RegisterToDateMessage = eRegisterToDate.Message;
						RegisterToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@RegisterToDate"].Value = RegisterToDateSQL;
				SqlDateTime PerformFromDateSQL = SqlDateTime.Null;
				if (PerformFromDate > DateTime.MinValue)
				{
					try
					{
						PerformFromDateSQL = PerformFromDate;
					}
					catch (Exception ePerformFromDate)
					{
						String PerformFromDateMessage = ePerformFromDate.Message;
						PerformFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PerformFromDate"].Value = PerformFromDateSQL;
				SqlDateTime PerformToDateSQL = SqlDateTime.Null;
				if (PerformToDate > DateTime.MinValue)
				{
					try
					{
						PerformToDateSQL = PerformToDate;
					}
					catch (Exception ePerformToDate)
					{
						String PerformToDateMessage = ePerformToDate.Message;
						PerformToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PerformToDate"].Value = PerformToDateSQL;
				SqlString PurposeSQL = Purpose;
				_dbadapter.UpdateCommand.Parameters["@Purpose"].Value = PurposeSQL;
				SqlString FormSQL = Form;
				_dbadapter.UpdateCommand.Parameters["@Form"].Value = FormSQL;
				SqlString LocationSQL = Location;
				_dbadapter.UpdateCommand.Parameters["@Location"].Value = LocationSQL;
				SqlInt32 QuantitySQL = Quantity;
				_dbadapter.UpdateCommand.Parameters["@Quantity"].Value = QuantitySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.UpdateCommand.Parameters["@Status"].Value = StatusSQL;
				SqlMoney MoneyOneEmployeeSQL = MoneyOneEmployee;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneEmployee"].Value = MoneyOneEmployeeSQL;
				SqlMoney MoneyOneCompanySQL = MoneyOneCompany;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneCompany"].Value = MoneyOneCompanySQL;
				SqlMoney MoneyOneTotalSQL = MoneyOneTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneTotal"].Value = MoneyOneTotalSQL;
				SqlMoney MoneyAllEmployeeSQL = MoneyAllEmployee;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllEmployee"].Value = MoneyAllEmployeeSQL;
				SqlMoney MoneyAllCompanySQL = MoneyAllCompany;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllCompany"].Value = MoneyAllCompanySQL;
				SqlMoney MoneyAllTotalSQL = MoneyAllTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllTotal"].Value = MoneyAllTotalSQL;
				SqlMoney MoneyTotalSQL = MoneyTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyTotal"].Value = MoneyTotalSQL;
				SqlString PartnerNameSQL = PartnerName;
				_dbadapter.UpdateCommand.Parameters["@PartnerName"].Value = PartnerNameSQL;
				SqlString PartnerPhoneSQL = PartnerPhone;
				_dbadapter.UpdateCommand.Parameters["@PartnerPhone"].Value = PartnerPhoneSQL;
				SqlString PartnerAddressSQL = PartnerAddress;
				_dbadapter.UpdateCommand.Parameters["@PartnerAddress"].Value = PartnerAddressSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.UpdateCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPositionSQL = PersonPosition;
				_dbadapter.UpdateCommand.Parameters["@PersonPosition"].Value = PersonPositionSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.UpdateCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonEmailSQL = PersonEmail;
				_dbadapter.UpdateCommand.Parameters["@PersonEmail"].Value = PersonEmailSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.UpdateCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_WELFARE_Update: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_WELFARE_Update: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_WELFARE_Disable(String WelfareCode, ref Boolean Enabled)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_WELFARE_Disable");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@enabled", SqlDbType.Bit));
				_dbadapter.UpdateCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.UpdateCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				_dbadapter.UpdateCommand.Parameters["@enabled"].Direction = ParameterDirection.Output;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_WELFARE_Disable: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_WELFARE_Disable: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_WELFARE_Delete(String WelfareCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.DeleteCommand = new SqlCommand("HRM_WELFARE_Delete");
				_dbadapter.DeleteCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.DeleteCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.DeleteCommand.Transaction = _trans;

				_dbadapter.DeleteCommand.Parameters.Clear();
				_dbadapter.DeleteCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.DeleteCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.DeleteCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.DeleteCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_WELFARE_Delete: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_WELFARE_Delete: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.DeleteCommand != null)
					_dbadapter.DeleteCommand.Dispose();
				CloseConnection();
			}
		}
		public Int32 HRM_WELFARE_Save(String WelfareCode, String WelfareName, DateTime PrepareFromDate, DateTime PrepareToDate, DateTime RegisterFromDate, DateTime RegisterToDate, DateTime PerformFromDate, DateTime PerformToDate, String Purpose, String Form, String Location, Int32 Quantity, Int32 Status, Decimal MoneyOneEmployee, Decimal MoneyOneCompany, Decimal MoneyOneTotal, Decimal MoneyAllEmployee, Decimal MoneyAllCompany, Decimal MoneyAllTotal, Decimal MoneyTotal, String PartnerName, String PartnerPhone, String PartnerAddress, String PersonName, String PersonPosition, String PersonPhone, String PersonEmail, String PersonAddress, String Description)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.UpdateCommand = new SqlCommand("HRM_WELFARE_Save");
				_dbadapter.UpdateCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.UpdateCommand.Connection = _dbconn;

				_trans = _dbconn.BeginTransaction();
				_dbadapter.UpdateCommand.Transaction = _trans;

				_dbadapter.UpdateCommand.Parameters.Clear();
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@WelfareName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PrepareFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PrepareToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RegisterFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@RegisterToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PerformFromDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PerformToDate", SqlDbType.DateTime));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Purpose", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Form", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Location", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Quantity", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneEmployee", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneCompany", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyOneTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllEmployee", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllCompany", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyAllTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@MoneyTotal", SqlDbType.Money));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerName", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PartnerAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonName", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPosition", SqlDbType.NVarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonPhone", SqlDbType.VarChar, 20));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonEmail", SqlDbType.VarChar, 100));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@PersonAddress", SqlDbType.NVarChar, 255));
				_dbadapter.UpdateCommand.Parameters.Add(new SqlParameter("@Description", SqlDbType.NVarChar, 1000));
				_dbadapter.UpdateCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.UpdateCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				SqlString WelfareNameSQL = WelfareName;
				_dbadapter.UpdateCommand.Parameters["@WelfareName"].Value = WelfareNameSQL;
				SqlDateTime PrepareFromDateSQL = SqlDateTime.Null;
				if (PrepareFromDate > DateTime.MinValue)
				{
					try
					{
						PrepareFromDateSQL = PrepareFromDate;
					}
					catch (Exception ePrepareFromDate)
					{
						String PrepareFromDateMessage = ePrepareFromDate.Message;
						PrepareFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PrepareFromDate"].Value = PrepareFromDateSQL;
				SqlDateTime PrepareToDateSQL = SqlDateTime.Null;
				if (PrepareToDate > DateTime.MinValue)
				{
					try
					{
						PrepareToDateSQL = PrepareToDate;
					}
					catch (Exception ePrepareToDate)
					{
						String PrepareToDateMessage = ePrepareToDate.Message;
						PrepareToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PrepareToDate"].Value = PrepareToDateSQL;
				SqlDateTime RegisterFromDateSQL = SqlDateTime.Null;
				if (RegisterFromDate > DateTime.MinValue)
				{
					try
					{
						RegisterFromDateSQL = RegisterFromDate;
					}
					catch (Exception eRegisterFromDate)
					{
						String RegisterFromDateMessage = eRegisterFromDate.Message;
						RegisterFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@RegisterFromDate"].Value = RegisterFromDateSQL;
				SqlDateTime RegisterToDateSQL = SqlDateTime.Null;
				if (RegisterToDate > DateTime.MinValue)
				{
					try
					{
						RegisterToDateSQL = RegisterToDate;
					}
					catch (Exception eRegisterToDate)
					{
						String RegisterToDateMessage = eRegisterToDate.Message;
						RegisterToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@RegisterToDate"].Value = RegisterToDateSQL;
				SqlDateTime PerformFromDateSQL = SqlDateTime.Null;
				if (PerformFromDate > DateTime.MinValue)
				{
					try
					{
						PerformFromDateSQL = PerformFromDate;
					}
					catch (Exception ePerformFromDate)
					{
						String PerformFromDateMessage = ePerformFromDate.Message;
						PerformFromDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PerformFromDate"].Value = PerformFromDateSQL;
				SqlDateTime PerformToDateSQL = SqlDateTime.Null;
				if (PerformToDate > DateTime.MinValue)
				{
					try
					{
						PerformToDateSQL = PerformToDate;
					}
					catch (Exception ePerformToDate)
					{
						String PerformToDateMessage = ePerformToDate.Message;
						PerformToDateSQL = SqlDateTime.Null;
					}
				}
				_dbadapter.UpdateCommand.Parameters["@PerformToDate"].Value = PerformToDateSQL;
				SqlString PurposeSQL = Purpose;
				_dbadapter.UpdateCommand.Parameters["@Purpose"].Value = PurposeSQL;
				SqlString FormSQL = Form;
				_dbadapter.UpdateCommand.Parameters["@Form"].Value = FormSQL;
				SqlString LocationSQL = Location;
				_dbadapter.UpdateCommand.Parameters["@Location"].Value = LocationSQL;
				SqlInt32 QuantitySQL = Quantity;
				_dbadapter.UpdateCommand.Parameters["@Quantity"].Value = QuantitySQL;
				SqlInt32 StatusSQL = Status;
				_dbadapter.UpdateCommand.Parameters["@Status"].Value = StatusSQL;
				SqlMoney MoneyOneEmployeeSQL = MoneyOneEmployee;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneEmployee"].Value = MoneyOneEmployeeSQL;
				SqlMoney MoneyOneCompanySQL = MoneyOneCompany;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneCompany"].Value = MoneyOneCompanySQL;
				SqlMoney MoneyOneTotalSQL = MoneyOneTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyOneTotal"].Value = MoneyOneTotalSQL;
				SqlMoney MoneyAllEmployeeSQL = MoneyAllEmployee;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllEmployee"].Value = MoneyAllEmployeeSQL;
				SqlMoney MoneyAllCompanySQL = MoneyAllCompany;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllCompany"].Value = MoneyAllCompanySQL;
				SqlMoney MoneyAllTotalSQL = MoneyAllTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyAllTotal"].Value = MoneyAllTotalSQL;
				SqlMoney MoneyTotalSQL = MoneyTotal;
				_dbadapter.UpdateCommand.Parameters["@MoneyTotal"].Value = MoneyTotalSQL;
				SqlString PartnerNameSQL = PartnerName;
				_dbadapter.UpdateCommand.Parameters["@PartnerName"].Value = PartnerNameSQL;
				SqlString PartnerPhoneSQL = PartnerPhone;
				_dbadapter.UpdateCommand.Parameters["@PartnerPhone"].Value = PartnerPhoneSQL;
				SqlString PartnerAddressSQL = PartnerAddress;
				_dbadapter.UpdateCommand.Parameters["@PartnerAddress"].Value = PartnerAddressSQL;
				SqlString PersonNameSQL = PersonName;
				_dbadapter.UpdateCommand.Parameters["@PersonName"].Value = PersonNameSQL;
				SqlString PersonPositionSQL = PersonPosition;
				_dbadapter.UpdateCommand.Parameters["@PersonPosition"].Value = PersonPositionSQL;
				SqlString PersonPhoneSQL = PersonPhone;
				_dbadapter.UpdateCommand.Parameters["@PersonPhone"].Value = PersonPhoneSQL;
				SqlString PersonEmailSQL = PersonEmail;
				_dbadapter.UpdateCommand.Parameters["@PersonEmail"].Value = PersonEmailSQL;
				SqlString PersonAddressSQL = PersonAddress;
				_dbadapter.UpdateCommand.Parameters["@PersonAddress"].Value = PersonAddressSQL;
				SqlString DescriptionSQL = Description;
				_dbadapter.UpdateCommand.Parameters["@Description"].Value = DescriptionSQL;
				Int32 returnvalue = Convert.ToInt32(_dbadapter.UpdateCommand.ExecuteScalar());

				_trans.Commit();
				return returnvalue;
			}
			catch (SqlException e)
			{
				try
				{
					_trans.Rollback();
				}
				catch (SqlException ex)
				{
					throw new Exception("SQL Rollback Error: HRM_WELFARE_Save: " + ex.Message, ex);
				}
				throw new Exception("SQL Error: HRM_WELFARE_Save: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.UpdateCommand != null)
					_dbadapter.UpdateCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_WELFARE_GetList()
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_WELFARE_GetList");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Prepare();
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_WELFARE_GetList: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
		public DataSet HRM_WELFARE_Get(String WelfareCode)
		{
			try
			{
				if (_dbconn.State != ConnectionState.Open)
					_dbconn.Open();
				_dbadapter.SelectCommand = new SqlCommand("HRM_WELFARE_Get");
				_dbadapter.SelectCommand.CommandType = CommandType.StoredProcedure;
				_dbadapter.SelectCommand.Connection = _dbconn;
				_dbadapter.SelectCommand.Parameters.Clear();
				_dbadapter.SelectCommand.Parameters.Add(new SqlParameter("@WelfareCode", SqlDbType.VarChar, 20));
				_dbadapter.SelectCommand.Prepare();
				SqlString WelfareCodeSQL = WelfareCode;
				_dbadapter.SelectCommand.Parameters["@WelfareCode"].Value = WelfareCodeSQL;
				_dbadapter.Fill(_data);

				return _data;
			}
			catch (SqlException e)
			{
				throw new Exception("SQL Error: HRM_WELFARE_Get: " + e.Message, e);
			}
			finally
			{
				if (_dbadapter.SelectCommand != null)
					_dbadapter.SelectCommand.Dispose();
				CloseConnection();
			}
		}
	}
}
